package xian.woniu.web.controller;

import org.springframework.web.bind.annotation.*;
import xian.woniu.entity.Lable;
import xian.woniu.service.ILableService;
import xian.woniu.util.ResultVO;

import java.util.List;

@RestController
@RequestMapping("lable")
public class LableController {
    private ILableService lableService;

    public LableController(ILableService lableService) {
        this.lableService = lableService;
    }

    @PostMapping("addlable")
    public ResultVO addLable(@RequestBody Lable lable){
        lableService.addLable(lable);
        return ResultVO.success("新增标签成功");
    }
    @PostMapping("deletelable")
    public ResultVO deleteLable(@RequestBody String lid){
        lableService.deleteLable(Integer.parseInt(lid));
        return ResultVO.success("删除成功");
    }
    @PostMapping("updatelable")
    public ResultVO updateLable(@RequestBody Lable lable){
        lableService.updateLable(lable);
        return  ResultVO.success("修改成功");
    }
    @GetMapping("findalllable")
    public ResultVO findAllLable(){
        List<Lable> lableList = lableService.findAllLable();
        return ResultVO.success(lableList);
    }
}
